#ifndef _CHAIN_H
#define _CHAIN_H

#include "../Globals/_cdslib_globals.h"
#include "../Node/_Node.h"

/* Generic Chain structure */
typedef struct {
    int type;
    size_t length;

    _Node *firstNode;
    _Node *previousNode;
    _Node *lastNode;
} _Chain;

/* Function prototypes */
void _initChain  (_Chain *initThis, int type); 
void _deleteChain(_Chain *deleteThis);

void  _ChainAdd      (_Chain *c, void  *addThis);
void *_ChainGet      (_Chain *c, size_t index);
void *_ChainSet      (_Chain *c, size_t index, void *setThis);
void  _ChainInsert   (_Chain *c, size_t index, void *insertThis);
void *_ChainExtract  (_Chain *c, size_t index);
void *_ChainPopFront (_Chain *c);
void *_ChainPopBack  (_Chain *c);
void  _ChainPushFront(_Chain *c, void  *pushThis);
void  _ChainPushBack (_Chain *c, void  *pushThis);

_Node *__ChainNodeGet(_Chain *c, size_t index);

#endif
